package com.config;


import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.ShearCaptcha;
import cn.hutool.captcha.generator.MathGenerator;
import org.springframework.context.annotation.Bean;

/**
 * @author Ychiha
 * @version 1.0
 * @date 10/1/2022 下午1:52
 */
public class CodeGenerator {

    @Bean
    public void makeCode(){

        ShearCaptcha captcha = CaptchaUtil.createShearCaptcha(200, 45, 4, 4);
        // 自定义验证码内容为四则运算方式
        captcha.setGenerator(new MathGenerator());
        captcha.write("d:/code.png");
        // 重新生成code
        captcha.createCode();

    }


}
